package com.microinvest.entity;
import com.microinvest.util.BigDecimalUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.Time;
@Data
@NoArgsConstructor
@AllArgsConstructor
//实体化用户卖出股票表
public class SellStock {
    private BigInteger sellId;
    private Integer userId;
    private String stockSymbol;
    private BigDecimal sellPrice;
    private Integer quantity;
    private BigDecimal totalAmount;
    private Time sellDate;
    private BigDecimalUtil bigDecimalUtil;

    public SellStock(Integer userId,String stockSymbol,BigDecimal sellPrice,Integer quantity){
        //计算totalAmount的double
        double totalAmountDouble = bigDecimalUtil.multiply(sellPrice.doubleValue(), quantity);
        //double转BigDecimal
        BigDecimal totalAmountDecimal = BigDecimal.valueOf(totalAmountDouble);
        this.userId=userId;
        this.stockSymbol=stockSymbol;
        this.sellPrice=sellPrice;
        this.quantity=quantity;
        this.totalAmount=totalAmountDecimal;

    }

}
